<!doctype html>
<html class="no-js fixed-layout">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>增加栏目</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="__Cssjs__/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="__Cssjs__/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="__Cssjs__/assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="__Cssjs__/assets/css/admin.css">
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
    以获得更好的体验！</p>
<![endif]-->

<header class="am-topbar am-topbar-inverse admin-header">
    {include file="public/head"}
</header>

<div class="am-cf admin-main">
    <!-- sidebar start -->
    {include file="public/sidebar"}
    <!-- sidebar end -->

    <!-- content start -->
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">新增栏目</strong></div>
            </div>
            <hr>
            <form class="am-form">
                <fieldset>
                    <label for="cate_m">所属栏目</label>
                    <div class="am-form-group">
                        <select id="cate_m" disabled> <!--增加disabled属性，禁止拉下框选择-->
                            <option value="0" selected>顶级栏目</option>
                            {volist name='category_list' id='cate'}
                            <option value="{$cate.id}">{$cate.name}</option>
                            {/volist}
                        </select>
                    </div>

                    <div class="am-form-group">
                        <label for="category_name">栏目名称</label>
                        <input type="text" class="" id="category_name" placeholder="输入栏目名称">
                    </div>

                    <p><button type="button" class="am-btn am-btn-default" onclick="post()">提交</button></p>
                </fieldset>
            </form>
        </div>
    </div>

    <!-- 测试弹出层 start-->
    <div class="am-modal am-modal-alert" tabindex="-1" id="success_alert">
        <div class="am-modal-dialog">

            <img class="am-modal-hd" src="__Cssjs__/assets/img/success.png">
            <div class="am-modal-bd">
                发表成功！
            </div>
            <div class="am-modal-footer">
                <span class="am-modal-btn">确定</span>
            </div>
        </div>
    </div>
    <!-- 测试弹出层 end-->

    <!-- content end -->
</div>

<a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: '#admin-offcanvas'}"></a>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="__Cssjs__/assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="__Cssjs__/assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="__Cssjs__/assets/js/amazeui.min.js"></script>
<script src="__Cssjs__/assets/js/amazeui.dialog.min.js"></script>
<script src="__Cssjs__/assets/js/app.js"></script>
<script src="__Cssjs__/vendor/wangEditor/dist/js/wangEditor.min.js"></script>
<link rel="stylesheet" href="__Cssjs__/vendor/wangEditor/dist/css/wangEditor.min.css">
<script type="text/javascript">
    var editor = new wangEditor('wangEdit');
    editor.create();
</script>
<script type="text/javascript">
    var category_m_id='';
    $(function () {
        category_m_id=$("#cate_m").val();
    });
    $("#cate_m").on('change',function () {
        category_m_id=$(this).val();
    });
    function post() {
        var category_name=$("#category_name").val();
        $.ajax({
            url:"/admin/category/category_add",
            type:"post",
            data:{"category_name":category_name,"category_m_id":category_m_id},
            dataType:"json",
            success:function (data) {
                if (data=='success'){
                    //$("#success_alert").modal(); 弹出层使用
                    AMUI.dialog.alert({
                        content:'提交成功！',
                        onConfirm: function() {
                            console.log('close');
                            window.location.href='/admin/category/add';
                        }
                    });

                }
            },
            error:function (jqXHR) {
                alert("AJAX错误，返回状态："+jqXHR.status);
            }
        })
    }
</script>
</body>
</html>